#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;

class Solution {
public:
    int missingNumber(vector<int>& nums) {
        unordered_set<int> hashtable;
        for (const auto& num : nums)
            hashtable.emplace(num);
        int res = 0;
        for (int i = 0;i <= nums.size();++i)
        {
            if (!hashtable.count(i))
            {
                res = i;
                break;
            }
        }
        return res;
    }
};